package com.origin.learn.redisson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.junit.Test;

import java.util.Map;

/**
 * @Description:
 * @Date: 2020/2/18
 * @Time: 18:55
 * @Created by:   dingtao
 * @Modified by:
 * @Modified at:
 */
public class T {

    @Test
    public void test(){
        String r = "[{\"aggregationcount\":8,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":6,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":6,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":6,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":5,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":5,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":5,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":5,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":5,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":4,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":4,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":4,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":4,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":4,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":4,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":4,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":4,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":4,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":4,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":4,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":4,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":3,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":3,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":3,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":3,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":3,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":3,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":3,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":3,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":3,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":3,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":3,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":3,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":3,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":3,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":2,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":2,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":2,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":2,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":2,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":2,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":2,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"172.16.0.12\"},{\"aggregationcount\":2,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":2,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":1,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":1,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain1\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":1,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":1,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":1,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":1,\"groupkey4\":\"192.16.0.33\",\"groupkey1\":\"domain2\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"},{\"aggregationcount\":1,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":1,\"groupkey4\":\"172.16.0.12\",\"groupkey1\":\"domain3\",\"groupkey3\":\"yidian\",\"groupkey2\":\"10.10.0.172\"},{\"aggregationcount\":1,\"groupkey4\":\"10.10.0.172\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":1,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"174.16.0.88\"},{\"aggregationcount\":1,\"groupkey4\":\"174.16.0.88\",\"groupkey1\":\"domain4\",\"groupkey3\":\"yidian\",\"groupkey2\":\"192.16.0.33\"}]";

        JSONArray list = JSON.parseArray(r);
        for (Object o : list) {
            Map<String, Object> map = (Map<String, Object>)o;
            Object x = map.get("aggregationCount");
            String count = String.valueOf(map.get("aggregationcount"));
//            logger.error("ErConstant.ES_AGG_COUNT):"+count);
            map.put("count", count);
            map.remove("aggregationCount");
//            allCount += Integer.parseInt(count);
        }

    }
}
